package src.leetcode.dp.medium_0198;

public class rob {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.rob(new int[]{1,2,3,1}));
    }
}

class Solution {
    public int rob(int[] nums) {
        int [][]dp = new int[nums.length + 1][2];

        for(int i = 1; i < nums.length + 1; i++){
            dp[i][0] = Math.max(dp[i-1][0], dp[i-1][1]);
            dp[i][1] = dp[i-1][0] + nums[i-1];
        }

        return Math.max(dp[nums.length][1], dp[nums.length][0]);
    }
}